{include file='admin/header.html'}

<link rel="stylesheet" href="{res file='res/kindeditor/themes/default/default.css'}">
<link rel="stylesheet" href="{res file='res/kindeditor/plugins/code/prettify.css'}">
<script charset="utf-8" src="{res file='res/kindeditor/kindeditor-all-min.js'}"></script>
{if in_array($lang, ['ar', 'en', 'ko', 'ru', 'zh-CN', 'zh-TW'])}
<script charset="utf-8" src="{$site_url}/static/res/kindeditor/lang/{$lang}.js"></script>
{else}
<script charset="utf-8" src="{res file='res/kindeditor/lang/en.js'}"></script>
{/if}
<script charset="utf-8" src="{res file='res/kindeditor/plugins/code/prettify.js'}"></script>
<script>
    KindEditor.ready(function (K) {
        window._editor1 = K.create('textarea[name="_content"]', {
            cssPath: '{$lang}' == 'mni-Mtei' ? ["{res file='res/kindeditor/plugins/code/prettify.css'}", "{res file='css/meetei-mayek.css'}"] : "{res file='res/kindeditor/plugins/code/prettify.css'}",
            uploadJson: "{$site_url}/{$lang}/admin/media/upload.html",
            fileManagerJson: "{res file='res/kindeditor/php/file_manager_json.php'}",
            allowFileManager: false,
            allowImageUpload: false,
            allowFlashUpload: false,
            allowMediaUpload: false,
            designMode: false,
        });
        window._editor1.readonly(false);
        window.editor1 = K.create('textarea[name="content"]', {
            cssPath: '{$lang}' == 'mni-Mtei' || '{$smarty.server.REQUEST_URI}'.split('?tlang=')[1] == 'mni-Mtei' ? ["{res file='res/kindeditor/plugins/code/prettify.css'}", "{res file='css/meetei-mayek.css'}"] : "{res file='res/kindeditor/plugins/code/prettify.css'}",
            uploadJson: "{$site_url}/{$lang}/admin/media/upload.html",
            fileManagerJson: "{res file='res/kindeditor/php/file_manager_json.php'}",
            allowFileManager: false,
            allowImageUpload: false,
            allowFlashUpload: false,
            allowMediaUpload: false,
            designMode: false,
        });
        window.editor1.readonly(false);
        prettyPrint();
    });
</script>

<form class="layui-form" action="">
    <fieldset class="layui-elem-field layui-field-title"><legend>{$localize.i18n}</legend></fieldset>
    {if $langs}
    <div class="layui-row">
        <div class="layui-col-md6">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">{$tran.language}</label>
                    <div class="layui-input-block">
                        <select name="_lang" lay-verify="required" disabled="disabled">
                            {foreach from="$langs" item="_lang"}
                            <option value="{$_lang.slug}" data-voice="{$_lang.voice}" {if $_lang.slug=='zh-CN'} selected="selected"{/if} disabled="disabled">{$_lang.name}（{$_lang.title}）</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-col-md6">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label"></label>
                    <div class="layui-input-inline">
                        <select name="lang" class="i18n-lang" data-id="{$row.id}" lay-filter="i18nlang" lay-verify="required">
                            <option value="">{$tran.choose}</option>
                            {foreach from="$langs" item="_lang"}
                            <option value="{$_lang.slug}" data-voice="{$_lang.voice}" {if $_lang.slug==$tlang} selected="selected"{/if} {if !in_array($_lang.slug, $lang_slugs) || $_lang.slug=='zh-TW'} disabled="disabled"{/if}>{$_lang.name}（{$_lang.title}）{if in_array($_lang.slug, $has_langs)}√{/if}</option>
                            {/foreach}
                        </select>
                    </div>
                    <div class="layui-form-mid" style="padding: 0 !important;">
                        <button type="button" class="layui-btn layui-btn-normal fill-translate"><i class="layui-icon layui-icon-fonts-clear"></i> {$tran.translate}</button> &nbsp;
                        <span id="chk-loading" class="layui-hide"><i class="layui-icon layui-icon-loading-1 layui-anim layui-anim-rotate layui-anim-loop"></i></span>
                    </div>
                </div>
            </div>
        </div>
    </div>
    {/if}
    <div class="layui-row">
        <div class="layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label">{$tran.artile_title}</label>
                <div class="layui-input-block">
                    <input type="text" name="_title" value="{$row.title}" required lay-verify="required" placeholder="{$tran.input_title}"
                        autocomplete="off" class="layui-input i18n-sl" disabled="disabled">
                </div>
            </div>
        </div>
        <div class="layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label i18n-tran">⇄</label>
                <div class="layui-input-block">
                    <input type="text" name="title" value="{if $row2}{$row2.title}{/if}" required lay-verify="required" placeholder="{$tran.input_title}"
                        autocomplete="off" class="layui-input i18n-tl">
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label">{$tran.slug}</label>
                <div class="layui-input-inline">
                    <input type="text" name="_slug" value="{$row.slug}" placeholder="" autocomplete="off" class="layui-input" disabled="disabled">
                </div>
            </div>
        </div>
        <div class="layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <div class="layui-input-inline">
                    <input type="text" name="slug" value="{if $row2}{$row2.slug}{else}{$row.slug}{/if}" placeholder="" autocomplete="off" class="layui-input" readonly="readonly">
                </div>
                <div class="layui-form-mid layui-word-aux">{$tran.not_modify}</div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-col-md6">
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">{$tran.content}</label>
                <div class="layui-input-block">
                    <textarea name="_content" placeholder="{$tran.input_content}" class="layui-textarea i18n-sl ke-editor"
                        style="width:100%;height:500px;visibility:hidden;" disabled="disabled">{$row.content|escape:html}</textarea>
                </div>
            </div>
        </div>
        <div class="layui-col-md6">
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label i18n-tran">⇄</label>
                <div class="layui-input-block">
                    <textarea name="content" placeholder="{$tran.input_content}" class="layui-textarea i18n-tl ke-editor"
                        style="width:100%;height:500px;visibility:hidden;">{if $row2}{$row2.content|escape:html}{/if}</textarea>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-col-md6">
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">{$tran.description}</label>
                <div class="layui-input-block">
                    <textarea name="_description" placeholder="" class="layui-textarea i18n-sl" disabled="disabled">{$row.description}</textarea>
                </div>
            </div>
        </div>
        <div class="layui-col-md6">
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label i18n-tran">⇄</label>
                <div class="layui-input-block">
                    <textarea name="description" placeholder="" class="layui-textarea i18n-tl">{if $row2}{$row2.description}{/if}</textarea>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label">{$tran.cover}</label>
                <div class="layui-input-inline">
                    <input type="text" name="_cover" value="{$row.cover}" placeholder="" autocomplete="off"
                        class="layui-input" disabled="disabled">
                </div>
            </div>
        </div>
        <div class="layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <div class="layui-input-inline">
                    <input type="text" name="cover" value="{if $row2}{$row2.cover}{else}{$row.cover}{/if}" placeholder="" autocomplete="off"
                        class="layui-input">
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label">{$tran.category}</label>
                <div class="layui-input-inline">
                    <select name="_category_id" lay-verify="required" class="i18n-sl">
                        <option value="">{$tran.choose}</option>
                        {foreach from="$category_tree" item="_category"}
                        <option value="{$_category.id}" {if $_category.id==$row.category_id} selected{/if}>{$_category.tree_name}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
        </div>
        <div class="layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label i18n-tran">⇄</label>
                <div class="layui-input-inline">
                    <select name="category_id" lay-verify="required" class="i18n-tl">
                        <option value="">{$tran.choose}</option>
                        {foreach from="$category_tree2" item="_category"}
                        <option value="{$_category.id}" {if $row2 && $_category.id==$row2.category_id} selected{/if}{if $_category.has_children} disabled{/if}>{$_category.tree_name}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label">{$tran.tag}</label>
                {if $tags}
                <div class="layui-input-block i18n-sl">
                    {foreach from="$tags" item="_tag"}
                    <input type="checkbox" name="_tag_ids[]" class="_tag_ids" value="{$_tag.id}" {if in_array($_tag.id, $tag_ids)} checked{/if} title="{$_tag.name|strip_tags}" {if !in_array($_tag.id, $tag_ids)} disabled="disabled"{/if}>
                    {/foreach}
                </div>
                {else}
                <div class="layui-input-inline">
                    <input type="text" name="_tags" value="" placeholder="{$tran.multi_tag} , {$tran.split}" autocomplete="off" class="layui-input" disabled="disabled">
                </div>
                {/if}
            </div>
            {if $tags}
            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <div class="layui-input-inline">
                    <input type="text" name="_tags" value="" placeholder="{$tran.multi_tag} , {$tran.split}" autocomplete="off" class="layui-input" disabled="disabled">
                </div>
            </div>
            {/if}
        </div>
        <div class="layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label i18n-tran">⇄</label>
                {if $tags2}
                <div class="layui-input-block i18n-tl">
                    {foreach from="$tags2" item="_tag"}
                    <input type="checkbox" class="tag_ids" name="tag_ids[]" value="{$_tag.id}" {if in_array($_tag.id, $tag_ids2)} checked{/if} title="{$_tag.name|strip_tags}">
                    {/foreach}
                </div>
                {else}
                <div class="layui-input-inline">
                    <input type="text" name="tags" value="" placeholder="{$tran.multi_tag} , {$tran.split}" autocomplete="off" class="layui-input i18n-tl">
                </div>
                {/if}
            </div>
            {if $tags2}
            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <div class="layui-input-inline">
                    <input type="text" name="tags" value="" placeholder="{$tran.multi_tag} , {$tran.split}" autocomplete="off" class="layui-input">
                </div>
            </div>
            {/if}
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label">SEO {$tran.title}</label>
                <div class="layui-input-block">
                    <input type="text" name="_seo_title" value="{$row.seo_title}" placeholder="" autocomplete="off"
                        class="layui-input i18n-sl" disabled="disabled">
                </div>
            </div>
        </div>
        <div class="layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label i18n-tran">⇄</label>
                <div class="layui-input-block">
                    <input type="text" name="seo_title" value="{if $row2}{$row2.seo_title}{/if}" placeholder="" autocomplete="off"
                        class="layui-input i18n-tl">
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-col-md6">
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">SEO {$tran.description}</label>
                <div class="layui-input-block">
                    <textarea name="_seo_description" placeholder="" class="layui-textarea i18n-sl" disabled="disabled">{$row.seo_description}</textarea>
                </div>
            </div>
        </div>
        <div class="layui-col-md6">
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label i18n-tran">⇄</label>
                <div class="layui-input-block">
                    <textarea name="seo_description" placeholder="" class="layui-textarea i18n-tl">{if $row2}{$row2.seo_description}{/if}</textarea>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label">{$tran.views}</label>
                <div class="layui-input-inline">
                    <input type="number" name="_views" value="{$row.views}" required lay-verify="required" placeholder="{$tran.input_views}"
                        autocomplete="off" class="layui-input" disabled="disabled">
                </div>
            </div>
        </div>
        <div class="layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <div class="layui-input-inline">
                    <input type="number" name="views" value="{if $row2}{$row2.views|modifier:intval}{else}0{/if}" required lay-verify="required" placeholder="{$tran.input_views}"
                        autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label">{$tran.likes}</label>
                <div class="layui-input-inline">
                    <input type="number" name="_likes" value="{$row.likes}" required lay-verify="required" placeholder="{$tran.input_likes}"
                        autocomplete="off" class="layui-input" disabled="disabled">
                </div>
            </div>
        </div>
        <div class="layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <div class="layui-input-inline">
                    <input type="number" name="likes" value="{if $row2}{$row2.likes|modifier:intval}{else}0{/if}" required lay-verify="required" placeholder="{$tran.input_likes}"
                        autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label">{$tran.author}</label>
                <div class="layui-input-inline">
                    <input type="text" name="_author" value="{$row.author}" required lay-verify="required" placeholder="{$tran.input_author}"
                        autocomplete="off" class="layui-input" disabled="disabled">
                </div>
            </div>
        </div>
        <div class="layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <div class="layui-input-inline">
                    <input type="text" name="author" value="{if $row2}{$row2.author}{else}{$row.author}{/if}" required lay-verify="required" placeholder="{$tran.input_author}"
                        autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label">{$tran.status}</label>
                <div class="layui-input-block">
                    <input type="hidden" name="_status" value="1" disabled="disabled">
                    <input type="checkbox" name="_status" value="0" {if $row.status==0} checked{/if} lay-skin="switch"
                        lay-text="ON|OFF" disabled="disabled">
                </div>
            </div>
        </div>
        <div class="layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <div class="layui-input-block">
                    <input type="hidden" name="status" value="1">
                    <input type="checkbox" name="status" value="0" {if !$row2 || $row2.status==0} checked{/if} lay-skin="switch"
                        lay-text="ON|OFF">
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label">{$tran.comment}</label>
                <div class="layui-input-block">
                    <input type="hidden" name="_can_comment" value="1" disabled="disabled">
                    <input type="checkbox" name="_can_comment" value="0" {if $row.can_comment==0} checked{/if} lay-skin="switch"
                        lay-text="ON|OFF" disabled="disabled">
                </div>
            </div>
        </div>
        <div class="layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <div class="layui-input-block">
                    <input type="hidden" name="can_comment" value="1">
                    <input type="checkbox" name="can_comment" value="0" {if !$row2 || $row2.can_comment==0} checked{/if} lay-skin="switch"
                        lay-text="ON|OFF">
                </div>
            </div>
        </div>
    </div>
    <br />
    <div class="layui-row">
        <div class="layui-col-md6">
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <div class="layui-form-mid" id="chk-res"></div>
                </div>
            </div>
        </div>
        <div class="layui-col-md6">
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <input type="hidden" name="_id" value="{$row.id}">
                    <input type="hidden" name="id" value="{if $row2}{$row2.id}{/if}">
                    <input type="checkbox" title="{$localize.auto}" data-next-id="{$nextId}" data-max-id="{$maxId}" lay-skin="primary" lay-filter="auto-db">
                    <button type="button" class="layui-btn check-i18n" lay-submit="" lay-filter="submit">{$tran.save}</button>
                    <button type="reset" class="layui-btn layui-btn-primary">{$tran.reset}</button>
                    <button type="button" class="layui-btn layui-btn-primary" lay-active="i18n_back">{$tran.back}</button>
                </div>
            </div>
        </div>
    </div>
</form>

{include file='admin/inc/form.html'}

{include file='admin/footer.html'}